import unittest 
import sys
import importlib.util
import logging
from unittest import TestCase, main

# 获取上上一层目录的路径
sys.path.append('../..')

# 动态导入模块
spec = importlib.util.spec_from_file_location("Square", "../../packageLib/square.py")
MyModule = importlib.util.module_from_spec(spec)
spec.loader.exec_module(MyModule)

   
class TestSquare(unittest.TestCase):

    def test_square(self):

        square = MyModule.Square(2)
        self.assertEqual(square.area(), 4)
    
    def test_square_negative(self):

        square = MyModule.Square(-2)
        self.assertEqual(square.area(), 4)
        
        
if __name__ == '__main__':
    unittest.main(verbosity=2)